<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style></style>
  </head>
  <body>
    <canvas id="canvas" width="1024" height="1024"></canvas>
  </body>
  <script>
    var canvas = document.querySelector("#canvas");
    var ctx = canvas.getContext("2d");
    // 填充矩形(x, y, width, height)
    ctx.fillRect(100, 100, 500, 500);
    // 清除矩形
    ctx.clearRect(150, 150, 400, 400);
    // 描边矩形
    ctx.strokeRect(200, 200, 300, 300);
  </script>
</html>
